package sseGameApps.service.mdkbr;

import org.slim3.datastore.Datastore;

import com.google.appengine.api.datastore.Transaction;

import sseGameApps.meta.mdkbr.MdDecorationMeta;
import sseGameApps.model.mdkbr.MdDecoration;

public class MdDecorationService {

    private MdDecorationMeta e = new MdDecorationMeta();

    public MdDecoration getMdDecoration(String userId) {

        MdDecoration data =
            Datastore.query(e).filter(e.userId.equal(userId)).asSingle();

        return data;
    }

    public void putMdDecoration(MdDecoration data) {

        Transaction tx = Datastore.beginTransaction();
        Datastore.put(data);
        tx.commit();

    }

    public MdDecoration setDefaultMdDecoration(String userId) {

        MdDecoration data = new MdDecoration();

        data.setUserId(userId);
        data.setEventComplete1(false);
        data.setEventComplete2(false);
        data.setEventComplete3(false);
        data.setEventComplete4(false);
        data.setEventComplete5(false);

        Transaction tx = Datastore.beginTransaction();
        Datastore.put(data);
        tx.commit();

        return data;

    }
}
